package com.ynwt.repository;

import com.ynwt.domain.UserEventLock;
import com.ynwt.enums.UserEventLockType;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;

/**
 * Created by huangying on 2017/5/11.
 */
@Repository
public interface UserEventLockDao extends PagingAndSortingRepository<UserEventLock, Integer> {

    @Lock(LockModeType.OPTIMISTIC_FORCE_INCREMENT)
    UserEventLock findByUserOpenidAndType(String openid, UserEventLockType type);

    int countByUserOpenidAndType(String openid, UserEventLockType type);
}
